require('../db');
let filmAndCinemasService = require('../service/filmAndCinemasService');

async function textFindAll() {
    let result = await filmAndCinemasService.findAll({})
    console.log(result);
    // console.log("cinema name为:" + result.rows[0].cinema.name); // 没有关联 会报错
    // console.log("film name为:" + result.rows[0].film.name);
}
// textFindAll();

async function textFind() {
    let result = await filmAndCinemasService.find({ film: '607fb9f485a0a107e40e89f1' }, { current: 1, size: 2 })
    console.log(result);
    console.log("cinema name为:" + result.rows[0].cinema.name);
    console.log("film name为:" + result.rows[0].film.name);
}
// textFind();

async function textFidnById() {
    console.log(await filmAndCinemasService.findById('607f9dc32d15ce13c4305077'));
}
// textFidnById();

async function textInsert() {
    console.log(await filmAndCinemasService.insert({
        cinema: "607fab69d9f56228ac8697f2",
        film: '607fabdb2f350e110c86c4c1',
        schedule: [
            { date: "2021/06/21", name: "一号厅", time: "12:00", price: 20 },
            { date: "2021/06/21", name: "二号厅", time: "12:00", price: 30 },
        ]
    }));
}
textInsert();

async function textUpdate() {
    console.log(await filmAndCinemasService.update('607fbafcc760df059cd20259', {
        cinema: '607fb96a96915c23cc6def73',
        film: '607fb9f485a0a107e40e89f1',
        schedule: [
            {
                date: "2021/04/22",
                screens: [
                    { name: "一号厅", time: "12:00", price: 100 },
                    { name: "二号厅", time: "12:00", price: 30 },
                ]
            }
        ]
    }));
}
// textUpdate();

async function textDelete() {
    console.log(await filmAndCinemasService.delete('607f9f07f48a4e39aceb7a24'));
}
// textDelete();


console.log(JSON.stringify([
    {
        date: "2021/04/21",
        screens: [
            { name: "一号厅", time: "12:00", price: 20 },
            { name: "二号厅", time: "12:00", price: 30 },
        ]
    }
]));